#ifndef __SocketIO_H__
#define __SocketIO_H__

#include "Packet.h"

namespace wd
{

class SocketIO
{
public:
    explicit
    SocketIO(int fd)
    : _fd(fd)
    {}

    //查看内核接收缓冲区有多少个字节
    int recvPeek(char * buff, int len) const;
    //确定发送len个字节的数据
    int sendn(const char * buff, int len) const;
    //确定接收len个字节的数据
    int readn(char * buff, int len) const;
    //每次接收一行数据, 在应用层的消息边界为'\n'
    int readline(char * buff, int maxlen) const;

    //读取 TLV 并解析为 Packet
    int readPacket(Packet& packet);
private:
    int _fd;
};

}//end of namespace wd


#endif

